package com.zhonghui.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.mes.domain.vo.MesInspectionStandardsVo;
import com.zhonghui.response.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.mes.domain.MesInspectionStandards;
import com.zhonghui.mes.service.IMesInspectionStandardsService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 检验标准Controller
 * 
 * @author yy
 * @date 2022-05-22
 */
@Api(tags="制造执行MES-检验标准")
@RestController
@RequestMapping("/mes/standards")
public class MesInspectionStandardsController extends BaseController
{
    @Autowired
    private IMesInspectionStandardsService mesInspectionStandardsService;

    /**
     * 查询检验标准列表
     */
    @ApiOperation("查询检验标准列表")
    @GetMapping("/list")
    public TableDataInfo<List<MesInspectionStandardsVo>> list(MesInspectionStandardsVo mesInspectionStandardsVo)
    {
        startPage();
        List<MesInspectionStandardsVo> list = mesInspectionStandardsService.selectMesInspectionStandardsList(mesInspectionStandardsVo);
        return getDataTable(list);
    }

    /**
     * 导出检验标准列表
     */
    @ApiOperation("导出检验标准列表")
    @Log(title = "检验标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesInspectionStandardsVo mesInspectionStandardsVo)
    {
        List<MesInspectionStandardsVo> list = mesInspectionStandardsService.selectMesInspectionStandardsList(mesInspectionStandardsVo);
        ExcelUtil<MesInspectionStandardsVo> util = new ExcelUtil<MesInspectionStandardsVo>(MesInspectionStandardsVo.class);
        util.exportExcel(response, list, "检验标准数据");

    }

    /**
     * 获取检验标准详细信息
     */
    @ApiOperation("获取检验标准详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<MesInspectionStandardsVo> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(mesInspectionStandardsService.selectMesInspectionStandardsById(id));
    }

    /**
     * 新增检验标准
     */
    @ApiOperation("新增检验标准")
    @Log(title = "检验标准", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody MesInspectionStandards mesInspectionStandards)
    {
        return BaseResult.success(mesInspectionStandardsService.insertMesInspectionStandards(mesInspectionStandards));
    }

    /**
     * 修改检验标准

     */
    @ApiOperation("修改检验标准")
    @Log(title = "检验标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody MesInspectionStandards mesInspectionStandards)
    {
        return BaseResult.success(mesInspectionStandardsService.updateMesInspectionStandards(mesInspectionStandards));
    }

    /**
     * 删除检验标准

     */
    @ApiOperation("删除检验标准")
    @Log(title = "检验标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(mesInspectionStandardsService.deleteMesInspectionStandardsByIds(ids));
    }
}
